/*
 * ImageResource.cpp
 *
 *  Created on: May 11, 2012
 *      Author: mklingen
 */

#include "ImageResource.h"

namespace kling
{

    ImageResource::ImageResource(std::string resourceName, std::string fileName) :
        kling::Resource(resourceName), m_fileName(fileName), m_image(NULL)
    {

    }

    ImageResource::~ImageResource()
    {
        if(m_image != NULL)
        {
            delete m_image;
            m_image = NULL;
        }
    }

    bool ImageResource::Initialize()
    {
        if(IsInitialized())
        {
            return true;
        }
        else
        {
            m_image = new sf::Image();

            if(!m_image->LoadFromFile(m_fileName))
            {
                return false;
            }
            else
            {
                return kling::Resource::Initialize();
            }
        }
    }

} /* namespace kling */
